#!/usr/env/bin python
#! coding:utf-8

"""
   创建应用，注册蓝本

"""
from flask.app import Flask
from flask_mail import Mail
from flask_login.login_manager import LoginManager
from flask_sqlalchemy import SQLAlchemy


app = Flask(__name__,static_url_path='/blog/static')
app.config.from_object('config.DevConfig')

db = SQLAlchemy(app)
mail = Mail(app)
## init flask_login

login_manager = LoginManager()
login_manager.session_protection = 'strong'  #session_protection 属性可以设为 None、'basic' 或 'strong
login_manager.login_view = 'auth_view.login'
# login_manager.anonymous_user = AnonymousUser #配置匿名用户，这个配置要做user_model.py中配置，因为AnonymousUser依赖login_manager,所以需要在login_manager init之后才能配置
login_manager.init_app(app)

from .model.user_model import AnonymousUser
login_manager.anonymous_user = AnonymousUser #配置匿名用户

## 注册蓝本
from .view.auth_view import auth
from .view.main_view import main
from .view.user_view import user

app.register_blueprint(main, url_prefix = '/blog')
app.register_blueprint(auth,url_prefix= '/blog/auth')
app.register_blueprint(user,url_prefix = '/blog/user')